﻿using System.Net.NetworkInformation;

namespace WebAppIdentity.HttpContexts
{
	public class HttpContextWrapper : IHttpContextWrapper
	{
		private readonly Microsoft.AspNetCore.Http.HttpContext? _httpContent;

		public HttpContextWrapper(IHttpContextAccessor httpContextAccessor)
		{
			_httpContent = httpContextAccessor.HttpContext;
		}
		public string? GetToken()
		{
			if (_httpContent != null && _httpContent.Request.Headers.TryGetValue("Authorization", out var token))
			{
				return token.ToString().Replace("Bearer ", "");

			}
			return null;
		}
	}
}
